﻿using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using FangDuShi_API.DBUtility;
using System.Data;

namespace FangDuShi_API.DAL
{
    /// <summary>
    /// 中介门店 数据类
    /// </summary>
    public class AgencyBranch
    {
        public AgencyBranch()
        { }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FangDuShi_API.Model.AgencyBranch DataRowToModel(DataRow row)
        {
            FangDuShi_API.Model.AgencyBranch model = new FangDuShi_API.Model.AgencyBranch();
            if (row != null)
            {
                if (row["FAgencyBranchID"] != null && row["FAgencyBranchID"].ToString() != "")
                {
                    model.FAgencyBranchID = decimal.Parse(row["FAgencyBranchID"].ToString());
                }
                if (row["FAgencyID"] != null && row["FAgencyID"].ToString() != "")
                {
                    model.FAgencyID = decimal.Parse(row["FAgencyID"].ToString());
                }
                if (row["FBranchBriefName"] != null)
                {
                    model.FBranchBriefName = row["FBranchBriefName"].ToString();
                }
                if (row["FBranchName"] != null)
                {
                    model.FBranchName = row["FBranchName"].ToString();
                }
                if (row["FLeaderName"] != null)
                {
                    model.FLeaderName = row["FLeaderName"].ToString();
                }
                if (row["FBranchTel"] != null)
                {
                    model.FBranchTel = row["FBranchTel"].ToString();
                }
                if (row["FBranchAddr"] != null)
                {
                    model.FBranchAddr = row["FBranchAddr"].ToString();
                }
                if (row["FLeaderMobile"] != null)
                {
                    model.FLeaderMobile = row["FLeaderMobile"].ToString();
                }
                if (row["FBusinessLicenseNo"] != null)
                {
                    model.FBusinessLicenseNo = row["FBusinessLicenseNo"].ToString();
                }
                if (row["FICNo"] != null)
                {
                    model.FICNo = row["FICNo"].ToString();
                }
                if (row["FICFile"] != null)
                {
                    model.FICFile = row["FICFile"].ToString();
                }
                if (row["FBusinessLicenseFile"] != null)
                {
                    model.FBusinessLicenseFile = row["FBusinessLicenseFile"].ToString();
                }
                if (row["FBaiduLongitude"] != null && row["FBaiduLongitude"].ToString() != "")
                {
                    model.FBaiduLongitude = decimal.Parse(row["FBaiduLongitude"].ToString());
                }
                if (row["FBaiduLatitude"] != null && row["FBaiduLatitude"].ToString() != "")
                {
                    model.FBaiduLatitude = decimal.Parse(row["FBaiduLatitude"].ToString());
                }
                if (row["FDispSeq"] != null && row["FDispSeq"].ToString() != "")
                {
                    model.FDispSeq = int.Parse(row["FDispSeq"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得中介公司门店数据列表
        /// </summary>
        public DataSet GetAgencyBranchList(decimal agencyID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FAgencyBranchID,FAgencyID,FBranchBriefName,FBranchName,FLeaderName,FBranchTel,FBranchAddr,FLeaderMobile,FBusinessLicenseNo,FICNo,FICFile,FBusinessLicenseFile,FBaiduLongitude,FBaiduLatitude,FDispSeq ");
            strSql.Append(" FROM t_AgencyBranch ");
            strSql.Append(" WHERE FAgencyID=@FAgencyID");

            SqlParameter[] parameters = {
					new SqlParameter("@FAgencyID", SqlDbType.Decimal,9)
			};
            parameters[0].Value = agencyID;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

    }
}
